/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Taxi.db.dao;

import Taxi.db.Database;
import Taxi.model.Operation;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author U24022
 */
public class OperationsDAO extends BaseDAO {
    
//    public int saveOperation(Operation operation) throws SQLException {
//        System.out.println("INSERT");
//        Statement statement;
//        statement = (Statement) Database.getConnection().createStatement();
//        String insertStr = "";
//        insertStr = "insert into operation (unitnumber, driver, startodometer, endodometer, platenumber, date, boundary) values("
//                + quotate(operation.getUnitnumber()) + ","
//                + quotate(operation.getDriver()) + ","
//                + quotate(operation.getStartodometer()) + ","
//                + quotate(operation.getEndodometer()) + ","
//                + quotate(operation.getPlatenumber()) + ","
//                + quotate(operation.getDate()) + ","
//                + quotate(operation.getBoundary())
//                + ")";

//        return statement.executeUpdate(insertStr);
//    }

//        public int updateOperation(Operation operation) throws SQLException {
//        System.out.println("UPDATE");
//        Statement statement;
//        statement = (Statement) Database.getConnection().createStatement();
//        String updateStr = "";
//        updateStr = "update operation set "
//                + "unitnumber ="+ operation.getUnitnumber()
//                + ", driver=" + quotate(operation.getDriver())
//                + ", startodometer="+ quotate(operation.getStartodometer())
//                + ", endodometer="+ quotate(operation.getEndodometer())
//                + ", platenumber="+ quotate(operation.getPlatenumber())
//                + ", date="+ quotate(operation.getDate())
//                + ", boundary="+ quotate(operation.getBoundary())
//                + " WHERE id=" + operation.getId();
//
//        return statement.executeUpdate(updateStr);
//    }

    public void deleteOperation(Operation operationFromTable) throws SQLException  {

           Statement statement;
        statement = (Statement) Database.getConnection().createStatement();
          int i = statement
              .executeUpdate("DELETE FROM OPERATION WHERE id = '"
                  + operationFromTable.getId() + "'");

    }
}
